package com.example.ByteStream;


import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Jason
 * @PACKAGE_NAME com.example.ByteStream
 * @Description 读取流InputStreamReader
 * @date 2023-12-13 14:25
 */
public class InputStreamReaderDemo {

    public static void main(String[] args) throws IOException {
        //1.创建流
        FileInputStream fis = new FileInputStream("d:\\bbb.txt");
//        InputStreamReader isr = new InputStreamReader(fis, "gbk");//乱码
        InputStreamReader isr = new InputStreamReader(fis, "utf-8");//正确;

        //2.读取文件
        int data = 0;
        while ((data = isr.read()) != -1) {
            System.out.print((char) data);
        }

        //3.关闭
        isr.close();

    }

}
